import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;

import br.ufpr.monografia.database.DBController;


public class TestarConexaoPostgres {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		try {
			
			DBController dbCon = new DBController();
			Connection con = dbCon.getConexao();

			PreparedStatement ps = con.prepareStatement("SELECT * from cliente.testetab ");
			ResultSet rs;
			ResultSetMetaData md;
			rs = ps.executeQuery();
			md = rs.getMetaData();
			int colunas = md.getColumnCount();
			for(int i=1; i<=colunas; i++) {
				System.out.print(md.getColumnName(i) + "\t");
			}
			System.out.println("");
			
			while(rs.next()) {
				for(int i=1; i<=colunas; i++) {
					System.out.print(rs.getString(i) + "\t");
				}
				System.out.println("");
			}
			
			
		}catch(Exception e) {
			e.printStackTrace();
		}

	}

}
